<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>删除页面上指定的p元素</title>
    <script>
        function delp() {
            //方法1
            var odiv = document.getElementById('odiv')
            var p1 = document.getElementById('p1')
            odiv.removeChild(p1)

            //方法2
            //p1.parentNode.removeChild(p1)
        }

    </script>
</head>

<body>
    <div id="odiv">
        <p id="p1">JavaScript程序设计</p>
        <p>JavaScript是一门功能强大的编程语言</p>
        <p>第一部分JavaScript概述</p>
        <p>JavaScript的发展历史</p>
        <input type="button" value="删除p元素" onclick="delp()">
    </div>
</body>

</html>